//Monday, November 30 2009
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class OrderedSuperString
{
public:
	int getLength(vector <string> words)
	{
		string superString = "";
        int last = 0;
        for (int k=0; k<words.size(); k++)
		{
			string w = words[k];
            for (int i = last; i <= superString.length(); i++)
			{  //checking all positions.
				int common = min(superString.length() - i, w.length());  //length of the overlapping part
		        string a = superString.substr(i, i + common);
                string b = w.substr(0, common);
                if (a == b)
				{  //match found
					superString += w.substr(common);
	                last = i;
	                break;
				}
			}
			cout << superString << endl;
		}
		return superString.length();
	}
};